package com.dc.refactoring._6_处理概括关系._10_FormTemplateMethod.step1;

import com.dc.refactoring._0_入门.Rental;

// step 2 根据多个情况，创建对应的子类
public class TextStatement extends Statement {

    /**
     * 普通打印会话
     */
    // step 3 将对应的函数搬移到 对应的“新建子类”中，并设置一个公共的函数名称
    public String value(Customer customer) {
        String result = customer.getName() + "的租赁记录信息为：\n";
        for (Rental rental : customer.getRentals()) {
            // 展示电影明细
            result += "\t" + rental.getMovie().getTitle() + "\t" + rental.getCharge() + "\n";
        }

        result += "总金额为：" + customer.getTotalCharge() + "\n";
        result += "你获得的积分为：" + customer.getTotalFrequentRenterPoints() + "\n";
        return result;
    }
}
